package com.itheima.service.impl;

import com.itheima.dao.UserDao;
import com.itheima.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.PropertySource;
import org.springframework.context.annotation.Scope;
import org.springframework.stereotype.Service;

import javax.annotation.PostConstruct;
import javax.annotation.PreDestroy;

@Service("userService")
@Scope("prototype")

public class UserServiceImpl implements UserService {

    @Value("${driver}")
    private String driver;
    @Value("${url}")
    private String  url;

    @Autowired
    private UserDao userDao;

    @PostConstruct
    public void  init(){
        System.out.println("UserServiceImpl init....");
    }
    @Override
    public void save() {
        System.out.println("UserServiceImpl run...");
        System.out.println(driver);
        System.out.println(url);
        userDao.save();
    }
    @PreDestroy
    public void destroy(){
        System.out.println("UserServiceImpl destroy");
    }

}
